

import static org.junit.Assert.*;

import org.junit.Test;

public class ContextCharacteristicsTest {

	
	@Test
	public void testSetGetBucketID() {
		
		ContextDefinition.setCCDFile("default.ccd");
		int numCtx = ContextDefinition.getContextDefinition().getNumContexts();
		ContextCharacteristics cs = new ContextCharacteristics();
		
		// set bucket ids
		for (int ctxidx=0; ctxidx<numCtx; ctxidx++) {
			int numBuckets = ContextDefinition.getContextDefinition().getContext(ctxidx).getNumberBuckets();
			cs.setBucketID(ctxidx, ctxidx % numBuckets);
		}
		
		// verify that the retrieved bucket ids match what we put in
		for (int ctxidx=0; ctxidx<numCtx; ctxidx++) {
			int numBuckets = ContextDefinition.getContextDefinition().getContext(ctxidx).getNumberBuckets();
			int expBucketID = ctxidx % numBuckets;
			assertEquals(expBucketID, cs.getBucketID(ctxidx));
		}
	}

}
